package com.css.crm.vo;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "customer-attribute")
public class CustomerAttributeVo extends AuditTrailVo {

	public CustomerAttributeVo() {
		super();

	}

	/** CUST_ATTR_ID **/
	private Long custAttrId;

	/** CUST_ID **/
	private String custId;
	/** ATTR_CDE **/
	private String attrCde;
	/** ATTR_VAL **/
	private String attrVal;
	/** REMARK1 **/
	private String remark1;
	/** REMARK2 **/
	private String remark2;

	@XmlElement
	public String getCustId() {
		return custId;
	}

	public void setCustId(String custId) {
		this.custId = custId;
	}

	@XmlElement
	public String getAttrCde() {
		return attrCde;
	}

	public void setAttrCde(String attrCde) {
		this.attrCde = attrCde;
	}

	@XmlElement
	public String getAttrVal() {
		return attrVal;
	}

	public void setAttrVal(String attrVal) {
		this.attrVal = attrVal;
	}

	@XmlElement
	public String getRemark1() {
		return remark1;
	}

	public void setRemark1(String remark1) {
		this.remark1 = remark1;
	}

	@XmlElement
	public String getRemark2() {
		return remark2;
	}

	public void setRemark2(String remark2) {
		this.remark2 = remark2;
	}

	public Long getCustAttrId() {
		return custAttrId;
	}

	public void setCustAttrId(Long custAttrId) {
		this.custAttrId = custAttrId;
	}

	@Override
	public int compareTo(AuditTrailVo o) {
		CustomerAttributeVo vo = (CustomerAttributeVo) o;
		if(vo == null){
			//if not set original data, default set to modified.
			return 1;
		}
		String custId = this.getCustId() == null ? "" : this.getCustId();
		String attrCode = this.getAttrCde() == null ? "" : this.getAttrCde();
		String attrValue = this.getAttrVal() == null ? "" : this.getAttrVal();
		String remark1 = this.getRemark1() == null ? "" : this.getRemark1();
		String remark2 = this.getRemark2() == null ? "" : this.getRemark2();
		
		String custIdCompareTo = vo.getCustId() == null ? "" : vo.getCustId();
		String attrCodeCompareTo = vo.getAttrCde() == null ? "" : vo.getAttrCde();
		String attrValueCompareTo = vo.getAttrVal() == null ? "" : vo.getAttrVal();
		String remark1CompareTo = vo.getRemark1() == null ? "" : vo.getRemark1();
		String remark2CompareTo = vo.getRemark2() == null ? "" : vo.getRemark2();


		// check if have any field be modified
		int result = 0;
		if (!custId.equals(custIdCompareTo)) {
			result = 1;
		}
		if (!attrCode.equals(attrCodeCompareTo)) {
			result = 1;
		}
		if (!attrValue.equals(attrValueCompareTo)) {
			result = 1;
		}
		if (!remark1.equals(remark1CompareTo)) {
			result = 1;
		}
		if (!remark2.equals(remark2CompareTo)) {
			result = 1;
		}
		return result;
	}

}
